package org.robot.scm.platform.monitor;

import lombok.extern.slf4j.Slf4j;
import org.robot.scm.pojos.config.BaseConfig;
import org.robot.scm.platform.AbstractMonitor;
import org.robot.scm.pojos.BaseNotify;
import org.robot.scm.pojos.enums.PlatformEnum;

/**
 * 基础配置更新
 */
@Slf4j
public class ConfigNoticeMonitor extends AbstractMonitor {

    private boolean delay = true;

    @Override
    public PlatformEnum getPlatform() {
        return PlatformEnum.CONFIG;
    }

    @Override
    public BaseNotify doMonitor(BaseConfig config) {
        if (delay) {
            log.info("{} delay ... ok", getPlatform().getVal());
            delay = false;
            return null;
        }
        String configPath = config.getCurrentPlatform().getNoticeSrc();
        AbstractMonitor.getMonitors().forEach(e -> e.refresh(configPath));
        return null;
    }
}
